package com.bst.bsj.common.dal.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.bst.bsj.common.dal.daointerface.SeedlingTypeDAO;
import com.bst.bsj.common.dal.dataobject.SeedlingType;
import com.sylinxsoft.tools.dao.impl.CommonBaseDAOImpl;

@Service("seedlingTypeDAO")
public class SeedlingTypeDAOImpl extends CommonBaseDAOImpl implements SeedlingTypeDAO {

  @Override
  public List<SeedlingType> getCounts(Map paramMap) {
    return (List<SeedlingType>) getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_QUERY_COUNT", paramMap);
  }

  @Override
  public List<SeedlingType> selectAll(Map paramMap, Long offset, Long length) {
    paramMap.put("offset", offset);
    paramMap.put("length", length);
    return (List<SeedlingType>) this.getSqlMapClientTemplate()
        .queryForList(getNameSpace() + ".MS_QUERY_PAGE", paramMap);
  }

  @Override
  public SeedlingType getSeedlingType(Long id) {
    return (SeedlingType) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_SELECT", id);
  }

  @Override
  public int update(SeedlingType seedlingType) {
    return getSqlMapClientTemplate().update(getNameSpace() + ".MS_UPDATE", seedlingType);
  }

  @Override
  public Long insert(SeedlingType seedlingType) {
    return (Long) getSqlMapClientTemplate().insert(getNameSpace() + ".MS_INSERT", seedlingType);
  }

  @Override
  public int delete(Long id) {
    return getSqlMapClientTemplate().delete(getNameSpace() + ".MS_DELETE", id);
  }

  @Override
  public List<SeedlingType> getAll() {
    return (List<SeedlingType>) this.getSqlMapClientTemplate().queryForList(getNameSpace() + ".MS_GETALL");
  }

  @Override
  public SeedlingType getByName(String name) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", name);
    return (SeedlingType) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_BY_NAME", map);
  }

  @Override
  public SeedlingType getCountByName(String name) {
    return (SeedlingType) getSqlMapClientTemplate().queryForObject(getNameSpace() + ".MS_GETCOUNT", name);
  }

}
